import common.CommonFunction;
import common.Mask;

import flash.events.MouseEvent;

import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.events.ListEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.validators.EmailValidator;

[Embed(source="/images/success.png")]private var successIcon:Class;
[Embed(source="/images/error.png")]private var errorIcon:Class;
[Embed(source="/images/question.png")]private var questionIcon:Class;

public var infoObject:Object;

public function onCreationComplete():void
{

}

public function cancel_clickHandler(event:MouseEvent):void
{
	phone_no.text = "";
	cust_name.text = "";
	dob.text = "";
	gender.selectedIndex = -1;
	address.text = "";
	city.selectedIndex = -1;
	country.selectedIndex = -1;
	state.selectedIndex = -1;
	zipcode.text = "";
	image_path.text = "";
	pan_image_path.text = "";
	voice_path.text = "";
	geo_long.text = "";
	imei.text = "";
	geo_lati.text = "";
	email_id.text = "";
	acc_bal.text = "";
}

public function submit_clickHandler(event:MouseEvent):void
{
	infoObject = new Object();
	infoObject["date"] = new Date();
	infoObject["phoneNo"] = phone_no.text;
	infoObject["custName"] = cust_name.text;
	infoObject["dob"] = dob.text;
	infoObject["gender"] = gender.selectedLabel;
	infoObject["address"] = address.text;
	infoObject["city"] = city.selectedLabel;
	infoObject["state"] = state.selectedLabel;
	infoObject["country"] = country.selectedLabel;
	infoObject["zipcode"] = zipcode.text;
	infoObject["imgPath"] = image_path.text;
	infoObject["panImgPath"] = pan_image_path.text;
	infoObject["voicePath"] = voice_path.text;
	infoObject["geoLong"] = geo_long.text;
	infoObject["geoLati"] = geo_lati.text;
	infoObject["imei"] = imei.text;
	infoObject["emailID"] = email_id.text;
	infoObject["accBal"] = acc_bal.text;
	setCustInformation.send(infoObject);
}

import flash.net.FileReference;
import flash.events.Event;
import flash.events.TextEvent;
import mx.core.IFactory;

public var fileReference:FileReference = new FileReference();
public function init():void
{
	fileReference.addEventListener(Event.SELECT, callUpload);
}

public function callUpload(event:Event):void
{
	
}

protected function img_path_clickHandler(event:MouseEvent):void
{
	fileReference.browse();	
}
public var customerXML:XML;
public function onSuccess(event:ResultEvent):void
{
	customerXML = event.result as XML;
	if(customerXML.booleanvalue == "true")
	{
		Alert.show(CommonFunction.getMessages('reqSuccess'), "Success");
	}
	else
	{
		Alert.show(CommonFunction.getMessages('reqFailure'), "Failure");
	}
}

public function onFaliure(event:FaultEvent):void
{
	Mask.close();
	Alert.show(event.message + "");
}

protected function country_changeHandler(event:ListEvent):void
{
	state.dataProvider = groupDB.country.(@name == country.selectedLabel).state.@name;
}

protected function state_changeHandler(event:ListEvent):void
{
	city.dataProvider = groupDB.country.(@name == country.selectedLabel).state.(@name == state.selectedLabel).city;
}

